class ManageFriend extends Scene{
    private manageArr:any  = [];
    private manageScroller:eui.Scroller;
    private needUp: boolean = false;
    private addFriendBtnImage:eui.Image;
    private manReturnFriendsImage:eui.Image;
    private manageList:eui.List;



    public constructor() {
        super();
        this.addEventListener(egret.Event.COMPLETE, this.addToStage, this);
      }
    
      public onSkinLoaded() {
          this.addFriendBtnImage.addEventListener(egret.TouchEvent.TOUCH_TAP, this.btnHandler, this);
          this.manReturnFriendsImage.addEventListener(egret.TouchEvent.TOUCH_TAP, this.btnHandler, this);
      }

    private btnHandler(evt: egret.TouchEvent) {
        let btnFocused = evt.currentTarget;   
        let deleteFlag:eui.Image = new eui.Image();
		switch (btnFocused) {
          case this.addFriendBtnImage:
              SceneManager.instance.addScene(new SearchFriend);
              break;
          case this.manReturnFriendsImage:
              SceneManager.instance.removeScene(this);
              break;
        }
    }

      private addToStage():void{
        for(var i:number=1;i<=10;i++){
          this.manageArr.push({item:i,name:"南华大学好友",skin:this,list:this.manageArr});
        }
        this.manageList.dataProvider=new eui.ArrayCollection(this.manageArr);
        this.manageList.itemRenderer=ManageFriendRenderer;
        this.manageScroller.addEventListener(eui.UIEvent.CHANGE, this.moveHandler, this);
        this.manageScroller.addEventListener(eui.UIEvent.CHANGE_END, this.outHandler, this);
      }

     
      private moveHandler(evt: eui.UIEvent): void {
		//检测是否超过滚动底部
		// console.log(this.moveScroll.viewport.scrollV);
		// console.log(this.moveScroll.viewport.contentHeight - this.moveScroll.viewport.height);
		console.log(this.manageScroller.viewport.scrollV > this.manageScroller.viewport.contentHeight - this.manageScroller.viewport.height);
		if(this.manageScroller.viewport.scrollV > (this.manageScroller.viewport.contentHeight - this.manageScroller.viewport.height)+40){
      this.needUp = true;
     }
  }
	private outHandler(evt:eui.UIEvent):void{
		//停止滚动时判断needUp是否为true;
		if(this.needUp){
			this.needUp = false;
      this.addToStage();
		}
  }

}